{% load form_helpers %}

<div class="form-group{% if field.errors %} has-error{% endif %}">
    {% if field|widget_type == 'checkboxinput' %}
        <div class="col-md-9 col-md-offset-3">
            <div class="checkbox{% if field.errors %} has-error{% endif %}">
                <label for="{{ field.id_for_label }}">
                    {{ field }} {{ field.label }}
                </label>
                {% if field.help_text %}
                    <span class="help-block">{{ field.help_text|safe }}</span>
                {% endif %}
            </div>
            {% if bulk_nullable %}
                <label class="checkbox-inline">
                    <input type="checkbox" name="_nullify" value="{{ field.name }}" /> Set null
                </label>
            {% endif %}
            {% if field.errors %}
                <ul>
                    {% for error in field.errors %}
                        <li class="text-danger">{{ error }}</li>
                    {% endfor %}
                </ul>
            {% endif %}
        </div>
    {% elif field|widget_type == 'textarea' and not field.label %}
        <div class="col-md-12">
            {{ field }}
            {% if bulk_nullable %}
                <label class="checkbox-inline">
                    <input type="checkbox" name="_nullify" value="{{ field.name }}" /> Set null
                </label>
            {% endif %}
            {% if field.help_text %}
                <span class="help-block">{{ field.help_text|safe }}</span>
            {% endif %}
            {% if field.errors %}
                <ul>
                    {% for error in field.errors %}
                        <li class="text-danger">{{ error }}</li>
                    {% endfor %}
                </ul>
            {% endif %}
        </div>
    {% else %}
        <label class="col-md-3 control-label{% if field.field.required %} required{% endif %}" for="{{ field.id_for_label }}">{{ field.label }}</label>
        <div class="col-md-9">
            {{ field }}
            {% if bulk_nullable %}
                <label class="checkbox-inline">
                    <input type="checkbox" name="_nullify" value="{{ field.name }}" /> Set null
                </label>
            {% endif %}
            {% if field.help_text %}
                <span class="help-block">{{ field.help_text|safe }}</span>
            {% endif %}
            {% if field.errors %}
                <ul>
                    {% for error in field.errors %}
                        <li class="text-danger">{{ error }}</li>
                    {% endfor %}
                </ul>
            {% endif %}
        </div>
    {% endif %}
</div>
